
from lib.api.SClass import scm
from hytest import STEP, INFO, CHECK_POINT


class Class1:
    name = "添加班级1 - tc000001"

    # 测试用例步骤
    def teststeps(self):
        STEP(1, "添加班级")

        res = scm.add_class(gradeid=1, name="七一班", studentlimit=60)
        retAdd = res.json()

        CHECK_POINT("添加结果检查", retAdd["retcode"] == 0)

        # 保存添加成功的班级ID
        self.classid = retAdd['id']

        STEP(2, "列出班级")

        res = scm.list_class(gradeid=1)
        retList = res.json()

        INFO(retList)

        expected = {
            "gradeid": 1,
            "retlist": [
                {
                    "name": "七一班",
                    "grade__name": "七年级",
                    "invitecode": retAdd['invitecode'],
                    "studentlimit": 60,
                    "studentnumber": 0,
                    "id": retAdd['id'],
                    "teacherlist": []
                }
            ],
            "retcode": 0
        }

        CHECK_POINT("列出结果检查", retList == expected)

    # 清除还原数据环境
    def teardown(self):
        scm.delete_class(classid=self.classid)


class Class6:
    name = "修改班级3 - tc000053"

    def teststeps(self):
        STEP(1, "修改班级")

        ret = scm.modify_class(classid=123456,
                               name="八二班", studentlimit=56)
        retAdd = ret.json()

        INFO(retAdd)

        CHECK_POINT("修改结果检查", retAdd['retcode'] == 404)


class Class7:
    name = "删除班级1 - tc000081"

    def teststeps(self):
        STEP(1, "删除班级")

        ret = scm.delete_class(classid=123456)
        retDelete = ret.json()

        INFO(retDelete)

        CHECK_POINT("删除结果检查", retDelete['retcode'] == 404)

